package com.dc.seckill.service;

import com.dc.seckill.dao.MiaoshaUserDao;
import com.dc.seckill.domain.MiaoshaUser;
import com.dc.seckill.domain.OrderInfo;
import com.dc.seckill.vo.GoodsVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @模块 秒杀模块
 * @作者 djs
 * @时间 2018/3/22 9:03
 * @版本 V1.0
 * @描述 提供秒杀处理的一些方法
 */
@Service
public class MiaoshaService {

    private Logger log = LoggerFactory.getLogger(MiaoshaService.class);

    @Autowired
    GoodsService goodsService;

    @Autowired
    OrderService orderService;

    @Autowired
    MiaoshaUserDao miaoshaUserDao;

    @Transactional
    public OrderInfo miaosha(MiaoshaUser user, GoodsVo goods) {
        //1:减库存
        goodsService.reduceStock(goods);
        //2:生成订单信息
        return orderService.createOrder(user,goods);
    }

}
